Skip to content

Conversation

@dorianmariecom
Copy link
Contributor

FIxes #168

ensure
ActiveRecord::Base.logger = previous_logger
terminate_process(pid) if pid && process_exists?(pid)
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated test coverage?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I had a hard time trying to reproduce the bug, I don't know the library very well, so happy for pointers for better ways to do it

def with_polling_volume
if SolidQueue.silence_polling?
if SolidQueue.silence_polling? && ActiveRecord::Base.logger
ActiveRecord::Base.logger.silence { yield }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better just use safe-navigation ActiveRecord::Base.logger&.silence ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then it will not yield

Copy link

@nbulaj nbulaj Mar 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But why? 🤔

irb(main):003> l = Logger.new(STDOUT)
irb(main):004> l.info { "OK" }
I, [2024-03-22T15:10:27.939697 #68513]  INFO -- : OK
=> true
irb(main):005> l&.info { "OK" }
I, [2024-03-22T15:10:31.957994 #68513]  INFO -- : OK
=> true


irb(main):008> n = nil
=> nil
irb(main):009> n&.info { "OK"  }
=> nil

Or I'd better have to think an example with yield, yes

@rosa rosa mentioned this pull request Apr 30, 2024
@rosa rosa merged commit 4b36e24 into rails:main Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

undefined method `silence' for nil (NoMethodError) with latest rails main

4 participants